Ví dụ OpenOffice Basic

Mặc dù OpenOffice Basic là một phiên bản tương tự như các phiên bản khác của ngôn ngữ BASIC,như VBA của Microsoft, giao diện lập trình ứng dụng(API) là rất khác, như ví dụ dưới đây của một macro minh họa. Trong khi có một cách dễ dàng hơn để có thể " đếm số đoạn văn" của một tài liệu, tví dụ cho thấy các phương pháp cơ bản để truy cập mỗi đoạn văn trong một tài liệu văn bản, liên tục.

Sub ParaCount'' Count number of paragraphs in a text document'    Dim Doc As Object, Enum As Object, TextEl As Object, Count As Long    Doc = ThisComponent' Is this a text document?    If Not Doc.SupportsService("com.sun.star.text.TextDocument") Then        MsgBox "This macro must be run from a text document", 64, "Error"        Exit Sub    End If    Count = 0' Examine each component - paragraph or table?    Enum = Doc.Text.CreateEnumeration    While Enum.HasMoreElements        TextEl = Enum.NextElement' Is the component a paragraph?        If TextEl.SupportsService("com.sun.star.text.Paragraph") Then            Count = Count + 1        End If    Wend'Display result    MsgBox Count, 0, "Paragraph Count"End Sub